package com.xmkj.jijidriver.mine.activity;

import android.support.v7.widget.LinearLayoutManager;

import com.common.adapter.helper.IRecyclerViewHelper;
import com.common.mvp.BaseMvpActivity;
import com.common.mvp.BasePresenter;
import com.common.utils.SizeUtils;
import com.common.widget.DividerDecoration.MarginDecoration;
import com.common.widget.recyclerview.refresh.recycleview.XRecyclerView;
import com.xmkj.jijidriver.R;
import com.xmkj.jijidriver.mine.adapter.MyCardsAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chen on 2018/4/1.
 */

public class MyCardActivity extends BaseMvpActivity {
    XRecyclerView recyclerview;
    private List<String> bean = new ArrayList<>();
    private MyCardsAdapter adapter;

    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_wash_record;
    }

    @Override
    protected void onViewCreated() {
        recyclerview = findViewById(R.id.recyclerview);
    }

    @Override
    protected void doLogicFunc() {
        bean.add("");
        bean.add("");
        bean.add("");
        gotoHttp();
        setRecyclerView();
    }
    private void setRecyclerView() {

        IRecyclerViewHelper.init().setRecycleLineLayout(context, LinearLayoutManager.VERTICAL, recyclerview);
        recyclerview.addItemDecoration(new MarginDecoration(LinearLayoutManager.VERTICAL, (int) SizeUtils.dp2px(context, 1)));
        recyclerview.setHasFixedSize(true);
        recyclerview.setRefreshing(false);
        adapter = new MyCardsAdapter(context, bean);
        recyclerview.setAdapter(adapter);


        recyclerview.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                mPageIndex = 1;
                mIsRefreshOrLoadMore = 0;
                gotoHttp();
            }

            @Override
            public void onLoadMore() {
                if (mIsHasNoData) {
                    recyclerview.loadMoreComplete();
                    recyclerview.setNoMore(true);
                    return;
                }
                mPageIndex++;
                mIsRefreshOrLoadMore = 1;
                gotoHttp();
            }
        });
    }

    private void gotoHttp() {

    }
    @Override
    protected void setNavigation() {
        setNavigationBack("我的优惠劵");
    }
}
